package com.yiyibook.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 文件上传 配置类
 *
 * @author yi.wu 2019-11-04 19:24:20
 */
@Configuration
public class UploadFilePathConfig implements WebMvcConfigurer {

    /**
     * 虚拟 访问路径
     */
    @Value("${file.staticAccessPath}")
    private String staticAccessPath;
    /**
     * 文件上传 绝对路径
     */
    @Value("${file.uploadFolder}")
    private String uploadFolder;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticAccessPath).addResourceLocations("file:" + uploadFolder);
    }

}
